home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.lanl.gov!tanmoy
- From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
- Newsgroups: comp.lang.c
- Subject: Re: What is &Variable (declared as: char Variable[10])?
- Date: 04 Mar 1996 15:10:26 GMT
- Organization: Los Alamos National Laboratory
- Message-ID: <TANMOY.96Mar4081026@qcd.lanl.gov>
- References: <4gqpa1$3h9@alcor.usc.edu> <4gtab6$acb@ceylon.gte.com>
- <4gvksnINNnug@anvil.ugrad.cs.ubc.ca>
- <TANMOY.96Feb29100937@qcd.lanl.gov>
- <4hdtfcINN4l3@keats.ugrad.cs.ubc.ca>
- NNTP-Posting-Host: qcd.lanl.gov
- Mime-Version: 1.0
- Content-Type: text
- In-reply-to: c2a192@ugrad.cs.ubc.ca's message of 3 Mar 1996 21:01:32 -0800
-
- In article <4hdtfcINN4l3@keats.ugrad.cs.ubc.ca>
- c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku) writes:
-
- <snip>
- KK: myarray is an expression whose evaluation calls for the generation
- of a value,
- KK: whose type is pointer to char and which points to the first
- element of myarray.
- KK: However, the expression myrray also has other attributes. It is an
- lvalue which
- KK: can be the subject of sizeof() and & operators, which are not
- interested in
- KK: computing the pointer value, but which look at the type and
- storage attributes
- KK: of myarray itself. It is not a modifiable lvalue, hence it cannot
- be assigned
- KK: to.
- <snip>
- KK: The bottom line is that it's not necessary to view the subjects of
- & and sizeof
- KK: as special cases; expressions are the same in the context of these
- operators as
- KK: they are anywhere else, and can be seen as producing the same
- values.
-
- One nit: One should not think of the value of the operand of sizeof
- because it is _not_ evaluated. Thus *(char*)0 is clearly undefined
- according to the standard, but sizeof *(char*)0 is valid.
-
- The difference you are trying to make between `value context' and
- `object context' (or `lvalue context') is a good way of understanding
- what is going on. In fact, I prefer this method of explaining it to
- beginners as well; though strictly speaking it is incorrect.
-
- It is actually a pity that the standard does not take that approach,
- and so even though you will get the same set of valid expressions: for
- invalid one's you will get different reasons for them being
- invalid. Thus if a are b are an arrays, by your logic the statement
- `a=b' is ruled out because the lvalue a is not modifiable and also
- because b is in a value context and hence does not remain an array to
- be assigned to a. On the other hand 6.2.2.1 makes clear that this is
- invalid because a in this context is not an lvalue!!! The difference
- is not important to most people: but I thought I would point it out
- just once.
-
- Cheers
- Tanmoy
- --
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-